package me.hys.api.company;

import java.util.Map;

import me.hys.entity.system.ConfigEntity;
import me.hys.service.system.IConfigManager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.common.collect.Maps;

/**
 * Author: @author HYS . <br>
 * Date: 2015-9-18 下午11:44:01 . <br>
 * Function: 公司简介
 */
@Controller
@RequestMapping("/api/profile")
public class ProfileApi {
	@Autowired
	private IConfigManager configManager;

	/**
	 * @Title : detail
	 * @Description : 公司简介详情
	 */
	@ResponseBody
	@RequestMapping("/get/{type}")
	public Map<String, String> get(@PathVariable int type) {
		// type 10公司简介（默认）， 20服务简介
		ConfigEntity config = configManager.findOneByFlags(getFlag(type));
		Map<String, String> data = Maps.newHashMap();
		if (null != config) {
			data.put("title", config.getTitle());
			data.put("content", config.getContent());
		}
		return data;
	}

	private String[] getFlag(int type) {
		if (type == 20) {
			return new String[] { "service" };
		} else {
			return new String[] { "company" };
		}
	}
}
